home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7887 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.1 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: What is &Variable (declared as: char Variable[10])?
  5. Date: 28 Feb 1996 21:56:31 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Feb28145631@qcd.lanl.gov>
  8. References: <4gqpa1$3h9@alcor.usc.edu> <4gsdno$1bg@umbc9.umbc.edu>
  9.     <4gtab6$acb@ceylon.gte.com> <313318b8.53776146@nntp.ix.netcom.com>
  10.     <4h1u9d$sqq@ceylon.gte.com>
  11. NNTP-Posting-Host: qcd.lanl.gov
  12. Mime-Version: 1.0
  13. Content-Type: text
  14. In-reply-to: Brenda's message of 28 Feb 1996 16:01:48 GMT
  15.  
  16. In article <4h1u9d$sqq@ceylon.gte.com>
  17. Brenda <g051286> writes:
  18.  
  19. <snip>
  20. B: What is the definition of a pointer?  I have always been taught that a
  21.  
  22. pointer is a cetgory of types. An array does not belong to this
  23. category. 
  24.  
  25. B: pointer is simply an address in memory, and an array name (i.e. myarray)
  26. B: is simply a CONSTANT address.  I don't think this statement is all that
  27.  
  28. You have always been taught wrong in that case. Just like after `int
  29. i;', i is not a constant address but the designator of a region of
  30. memory, after `int j[5];', j is a designator of another region of
  31. memory. 
  32.  
  33. B: radical.  Of course there are differences between arrays and pointers
  34.  
  35. I agree it is not a radical mistake: it is a mistake which is often
  36. made. What we hope would some day be radical is for people like you to
  37. post without reading the FAQ which explains this and many other issues.
  38.  
  39. B: due to the fact that an array is a CONSTANT address and a pointer is a
  40. B: VARIABLE address.  And the reason I said you shouldn't (note shouldn't
  41.  
  42. The problem is much more serious. An array is not an address in any
  43. sense, constant or not.
  44.  
  45. B: not couldn't) say &myarray is:
  46. B: 
  47. B: ==================================================
  48. B: (from "A Book On C", Kelley & Pohl, pg 200)
  49. B: Constructs not to be pointed at:
  50. B: 1. Do not point at constants. (&3)
  51. B: 2. Do not point at arrays; an array name is a constant. (int a[77]; &a)
  52.  
  53. This statement is incorrect. &a is perfectly valid C. C is currently
  54. defined by an international standards doucment, and that clearly
  55. allows address of arrays. Please do not try to argue from completely
  56. outdated or mistaken books.
  57.  
  58. B: 3. Do not point at ordinary expressions &(k + 99)
  59. B: 4. Do not point at register variables. (register v; &v)
  60. B: The address operator can be applied to variables and array elements.
  61.  
  62. And to functions, non-bitfield struct or union members, and arrays.
  63.  
  64. B: ===================================================
  65. B: 
  66. B: So again I say, myarray is DEFINITELY a pointer (i.e. address in memory).
  67. B: 
  68.  
  69. And you will be wrong again. Please learn C as it is today, and has
  70. been for quite a while now, before posting further.
  71.  
  72. Cheers
  73. Tanmoy
  74. --
  75. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  76. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  77. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  78. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  79. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  80. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  81.